#!/bin/bash
# /**
# * Copyright (c) 2018, yzfcer@163.com
# * All rights reserved.
# * @file    delete_swp.sh
# * @brief   可以清理某个目录下的vim的缓存文件
# * @author  Jason Zhou,yzfcer@163.com
# * @version 1.0
# * @date    2021-09-15
# */

function usage()
{
    echo "delete_swp uasge:"
    echo "delete_swp <dir>"
}

function main()
{
    if [ $# -lt 1 ]
    then
        echo "miss argument"
        usage
        exit
    fi
    echo "delete switch files:$1"

    ftypes="-name .*.swp"
    ftypes+=" -o -name .*.swo"
    ftypes+=" -o -name .*.swm"
    ftypes+=" -o -name .*.swn"
    ftypes+=" -o -name .*.swl"

    # echo "find $1 $ftypes | xargs echo"
    find $1 $ftypes | xargs echo
    find $1 $ftypes | xargs rm -rf
}

main $@
